#include "huanbutton.h"
#include "ui_huanbutton.h"
#include "qqtframe.h"

HuanButton::HuanButton ( QWidget* parent ) :
    QQtClickWidget ( parent ),
    ui ( new Ui::HuanButton )
{
    ui->setupUi ( this );
    setContentsMargins ( 0, 0, 0, 0 );
    //setImageStyle ( QQTZOOM );

    //ui->widget->setAttribute ( Qt::WA_TransparentForMouseEvents, true );
    //ui->label->setAttribute ( Qt::WA_TransparentForMouseEvents, true );
    ;

    connect ( ui->widget, SIGNAL ( click() ), this, SIGNAL ( click() ) );
}

HuanButton::~HuanButton()
{
    delete ui;
}

QString HuanButton::text()
{
    return ui->label->text();
}

QString HuanButton::icon()
{
    return mIcon;
}

QWidget* HuanButton::widget()
{
    return ui->widget;
}

void HuanButton::setText ( QString btnText )
{
    ui->label->setText ( btnText );
}

void HuanButton::setIcon ( QString icon )
{
    mIcon = icon;
    /*QSS美化，和QQtClickWidget图片背景不能共存，但是QSS部分能够影响QQtClickWidget*/
    ui->widget->setPixmap ( icon );
}

void HuanButton::setIconSize ( QSize size )
{
    ui->widget->setFixedSize ( size );
    update();
}

QSize HuanButton::iconSize()
{
    return ui->widget->size();
}

void HuanButton::setTextFont ( const QFont& font )
{
    ui->label->setFont ( font );
    ui->label->setFixedHeight ( ui->label->fontMetrics().height() );
    update();
}

void HuanButton::initCloseIcon()
{
    closeWidget.setGeometry ( this->width() - 10, 0, 10, 10 );
    closeWidget.setPixmap ( skin ( "demo/icon_close.png" ) );
}
